package com.hong.arithmetic.base;

/**
 * @author: csh
 * @Date: 2021/6/27 10:03
 * @Description:递归算法
 */
public class Recursion {
    public static void main(String[] args) {
        int sum = 0;
        for(int i =0;i<=100;i++){
            sum+=i;
        }
        System.out.println(sum);
        System.out.println(sum(100));
    }

    public static int sum(int i){
        if(i!=0){
            return i+=sum(i-1);
        }else{
            return i;
        }
    }
}
